#include <regx52.h>    
#include "Delay.h"
#include "max7219.h"
#include "IR.h"

void main()
{
	unsigned char Command,addr,i;

	Delay(500);
	Max7219_Init();
	IR_Init();
	
	Max7219_Clear();
	
	while(1)
	{
		if(IR_GetDataFlag())	     //如果收到数据帧
		{                                               
			Max7219_Clear();
			Command=IR_GetCommand(); //获取遥控器命令码
			
			addr = 0x00;
			for(i=0; i<8; i++) {
				addr += 1;
				if(Command & (1<<i)){
					WriteMax7219(addr, 0x30); //写1
				}else{
					WriteMax7219(addr, 0x7e); //写0
				}
			}
		}
	}
}